package com.tuju.currency.utils;

import android.content.Context;
import android.widget.Toast;

import com.tuju.currency.App;

/**
 * Created by 彦泽 on 2018/7/12.
 */

public class ToastUtils {
    public static Toast mToast;
    public static boolean isDebug = false;

    public static void showDebugToast(Context context, String message) {
        if (!isDebug) {
            return;
        }
        Toast.makeText(context, message, Toast.LENGTH_SHORT);
        mToast.setText(message);
        mToast.show();
    }

    public static void showDebugToast(String message) {
        if (!isDebug) {
            return;
        }
        if (mToast == null) {
            mToast = Toast.makeText(App.instrance, message, Toast.LENGTH_SHORT);
        }
        mToast.setText(message);
        mToast.show();
    }

    public static void showToast(String message) {
        if (mToast == null) {
            mToast = Toast.makeText(App.instrance, message, Toast.LENGTH_SHORT);
        }
        mToast.setText(message);
        mToast.show();
    }

    public static void showToast(int stringId) {
        if (mToast == null) {
            mToast = Toast.makeText(App.instrance, stringId, Toast.LENGTH_SHORT);
        } else {
            mToast.setText(stringId);
        }
        mToast.show();
    }

    public static void cancel() {
        if (mToast != null) {
            mToast.cancel();
        }
    }
}
